ioemu: error checkin when setting up the Cirrus Logic video device.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 28 Aug 2007 15:08:38 +0000 (16:08 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 28 Aug 2007 15:08:38 +0000 (16:08 +0100)
set_mm_mapping() may fail because of xc_domain_populate_physmap().  In
this case, we should not blindly go on; the xc_map_foreign_batch()
that follows will cause a page fault and, at best, get mapped in a
zeroed page from the dom0 (which is not what we want).  While I'm in
here, fix a memory leak on an error path.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
tools/ioemu/hw/cirrus_vga.c

index fb2f3ae556819bf8200ca663473e4d04c256fe2f..cc73390716c1a077bd890769c5a4e6350b5e2ebe 100644 (file)
@@ -2559,7 +2559,11 @@ static void *set_vram_mapping(unsigned long begin, unsigned long end)
     for (i = 0; i < nr_extents; i++)
         extent_start[i] = (begin + i * TARGET_PAGE_SIZE) >> TARGET_PAGE_BITS;
 
-    set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
+    if (set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start) < 0) {
+        fprintf(logfile, "Failed set_mm_mapping\n");
+        free(extent_start);
+        return NULL;
+    }
 
     vram_pointer = xc_map_foreign_batch(xc_handle, domid,
                                         PROT_READ|PROT_WRITE,
@@ -2567,6 +2571,7 @@ static void *set_vram_mapping(unsigned long begin, unsigned long end)
     if (vram_pointer == NULL) {
         fprintf(logfile, "xc_map_foreign_batch vgaram returned error %d\n",
                 errno);
+        free(extent_start);
         return NULL;
     }